package com.zmn.plat.admin.controller.online.service.group.product.group;

import com.zmn.common.dto2.ResponseDTO;
import com.zmn.plat.model.entity.online.service.group.product.group.OnlineServiceGroupProductGroup;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 在线客服分组产品组配置
 *
 * @author linfeng
 *
 * @since 2021-03-26 17:21:53
 */
@RestController
@RequestMapping("/online/service/group/product/group/")
public class OnlineServiceGroupProductGroupModifyController extends OnlineServiceGroupProductGroupBaseController  {

    /**
     * 配置产品组
     * @param list
     * @return
     */
    @RequestMapping(value = "configProductGroup")
    @ResponseBody
    @RequiresPermissions("/online/service/group/product/group/detail.action")
    public ResponseDTO configProductGroup(@RequestBody List<OnlineServiceGroupProductGroup> list) {
        if (CollectionUtils.isEmpty(list)) {
            return ResponseDTO.fail("请选择要配置的产品组！");
        }

        String operator = getMcStaffRealName();

        try {
            onlineServiceGroupProductGroupBService.configProductGroup(list, operator);
            return ResponseDTO.success(true, "操作成功！");
        } catch (Exception e) {
            logger.error("configProductGroup error", e);
            return ResponseDTO.fail("系统异常");
        }
    }
}
